//app.js
App({
  onLaunch: function () {
    require('./sdk-v1.0.4');
    // clientID 在 BaaS 后台获取
    var that = this;
    wx.BaaS.init(this.globalData.CLIENTID);
    that.globalData.BASS_API_URL = wx.BaaS._config.API_HOST;
    //  wx.BaaS.logout();
    wx.BaaS.login().then((res) => {
      // success
      console.log(res);
      that.globalData.userInfo.userId = wx.BaaS.storage.get('uid');
    }, (err) => {
      console.log("baas login err " + err);
    });
  },
  globalData: {
    IS_AUTH: false,
    BASS_API_URL: '',

    STATIC_URL: "http://ifanr.b0.upaiyun.com/beijiang/",

    CLIENTID: 'YgNW1t5FSCNs5Q2Q', // BAAS分配
    userInfo: {}, // TODO BASS封装后的用户信息

    relateNum: 4, // 相关数量
    fabricClothNum: 6, // 面料所做成衣数量
    relateBathNum: 20, // 一次拉回来多少随机

    TABLE_ID_CATEGORY: 1,
    TABLE_ID_PRODUCT: 2,
    TABLE_ID_VENDOR: 3,
    TABLE_ID_PRODUCT_SKU: 4,
    TABLE_ID_PRODUCT_FAVORITE: 5,
    TABLE_ID_SHOPPING_CART: 6,
    TABLE_ID_ADDRESS_BOOK: 7,
    TABLE_ID_BANNER: 8,
    TABLE_ID_ORDER: 9,
    TABLE_ID_SUPPORT: 11,
    TABLE_ID_ORDER_ITEM: 27,

    ALL_CATEGORY: [], // TODO BAAS获取 这里要获取所有成衣分类后合并 id: '', name:''
    ALL_CATEGORY_ID: 1, // 成衣ID
    WOMEN_CATEGORY_ID: 4, // 女装分类ID
    MEN_CATEGORY_ID: 5, // 男装分类ID
    KIDS_CATEGORY_ID: 6, // 童装分类ID
    RECOMMEND_CATEGORY_ID: 3, // 新品推荐分类ID
    RECOMMEND_ALL_CATEGORY_ID: 24, // 新品推荐 全部 分类ID
    RECOMMEND_MEN_CATEGORY_ID: 22, // 新品推荐 男装 分类ID
    RECOMMEND_WOMEN_CATEGORY_ID: 21, // 新品推荐 女装 分类ID
    RECOMMEND_KIDS_CATEGORY_ID: 23, // 新品推荐 童装 分类ID

    MEN_CATEGORY: [], // TODO BAAS获取
    WOMEN_CATEGORY: [], // TODO BAAS获取
    KIDS_CATEGORY: [], // TODO BAAS获取

    RECOMMEND_ALL_CATEGORY: [], // TODO BASS获取
    RECOMMEND_MEN_CATEGORY: [], // TODO BASS获取
    RECOMMEND_WOMEN_CATEGORY: [],
    RECOMMEND_KIDS_CATEGORY: [],

    ALL_FILTER: [{
      id: 1,
      name: '裤型',
      field: 'style',
      childs: [
        { id: 1, name: '紧身' },
        { id: 2, name: '修身' },
        { id: 3, name: '直筒' },
        { id: 4, name: '阔脚' },
        { id: 5, name: '标准' }
      ]
    }, {
      id: 2,
      name: '水洗颜色',
      field: 'color',
      childs: [
        { id: 6, name: '深' },
        { id: 7, name: '中' },
        { id: 8, name: '浅' }
      ]
    }, {
      id: 3,
      name: '成分',
      field: 'component',
      childs: [
        { id: 9, name: '全棉' },
        { id: 10, name: '弹力' },
        { id: 11, name: '天丝' },
        { id: 12, name: '环保' }
      ]
    }, ],
    ORDER_CATEGORY: [
      { id: 1, name: '重量从低到高', orderBy: 'mass' },
      { id: 2, name: '重量从高到低', orderBy: '-mass' },
      { id: 3, name: '弹力从低到高', orderBy: 'elasticity' },
      { id: 4, name: '弹力从高到低', orderBy: '-elasticity' }
    ],

    FABRIC_CATEGORY_ID: 2, // 面料分类ID
    FABRIC_CATEGORY: [], // TODO BAAS获取
    FABRIC_FILTER: [{
      id: 1,
      name: '成分',
      field: 'component',
      childs: [
        { id: 1, name: '全棉', filterTxt: '全棉' },
        { id: 2, name: '天丝', filterTxt: '天丝' },
        { id: 3, name: '弹力', filterTxt: '弹力' },
        { id: 4, name: '环保', filterTxt: '环保' },
        { id: 5, name: '功能', filterTxt: '功能' }
      ]
    }, {
      id: 2,
      name: '重量',
      field: 'mass',
      childs: [
        { id: 1, name: '<7 oz', filterTxt: '<7' },
        { id: 2, name: '7 – 9 oz', filterTxt: 'r7,9' },
        { id: 3, name: '9 – 10.5 oz', filterTxt: 'r9,10.5' },
        { id: 4, name: '10.5 – 12 oz', filterTxt: 'r10.5,12' },
        { id: 5, name: '>12 oz', filterTxt: '>12' },
      ]
    }, {
      id: 3,
      name: '弹力',
      field: 'elasticity',
      childs: [
        { id: 1, name: 'Non', filterTxt: '<1' },
        { id: 2, name: '<30%', filterTxt: 'r1,30' },
        { id: 3, name: '30-50%', filterTxt: 'r30,50' },
        { id: 4, name: '>50%', filterTxt: '>50' }
      ]
    }]
  }
})
